// app.js
import tim from  './utils/tim-sdk/tim.js'
import timUser from './utils/tim-sdk/userSig'
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
      // 开始登录 
      // 登录tim
    tim.login({userID: 'user0', userSig: timUser.user0});
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData: {
    userInfo: null,
    messageReceivedObj:{},
    timInstance: tim,
    timSDKReady:false
  },
    /**
   * 防止短时间内重复点击的问题
   */
  throttle(gapTime) {
    if (gapTime == null || gapTime == undefined) {
      gapTime = 1000
    }
    let nowTime = (new Date()).getTime();
    if (this.lastTime == null || nowTime - this.lastTime > gapTime) {
      this.lastTime = nowTime;
      return true;
    }
    // 返回新的函数
    return false;
  },
})
